/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package occho.model;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.util.ArrayList;
import javax.swing.*;

/**
 *
 * @author Juan Antonio
 */
public class MyCellRenderer extends JLabel implements ListCellRenderer{
    ArrayList<ImageIcon> liconos;
    
    /**
     * Constructor de la clase.
     * @param liconos
     */
    public MyCellRenderer(ArrayList<ImageIcon> liconos){
        this.liconos=liconos;
    }
    
    public Component getListCellRendererComponent(
            JList list, 
            Object value, // value to display
            int index, // cell index
            boolean isSelected, // is the cell selected
            boolean cellHasFocus){ // the list and the cell have the focus
   
        setText("Pregunta "+(index+1));
        //setIcon(this.liconos.get(0));
        PreguntaAlumno pa=(PreguntaAlumno)value;
        if(pa.isContestada()){
           if(pa.isAcertada()){
               setIcon(this.liconos.get(0));
           } 
           else{
               setIcon(this.liconos.get(1));
           }
        }
        else{
            setIcon(this.liconos.get(2));
        }
        
        if(isSelected){
            setBackground(Color.BLUE);
            setForeground(Color.WHITE);
            setFont(new Font("Tahoma", Font.BOLD, 13));
            setOpaque(true);
        }
        else{
            //setBackground(Color.WHITE);
            setForeground(Color.BLACK);
            setFont(new Font("Tahoma", Font.PLAIN, 11));
            setOpaque(false);   
        }
        
        
        //setIcon(longIcon);
        return this;
    }
}
